package com.softa.web.controller.system;

import java.util.List;

import javax.annotation.Resource;

import com.softa.annotation.CurrentUser;
import com.softa.dao.model.SysResource;
import com.softa.dao.model.SysUser;
import com.softa.service.system.ResourceService;
import com.softa.service.system.UserService;
import com.softa.utils.Constants;
import com.softa.web.controller.base.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
* @ClassName: IndexController
* @Description: TODO
* @author yangl
* @date 2015-6-5 下午1:35:29
*
 */
@Controller
public class IndexController extends BaseController {

    @Resource
    private ResourceService resourceService;
    @Resource
    private UserService userService;

    @RequestMapping("/")
    public String index(@CurrentUser SysUser loginUser, Model model) {
//        Set<String> permissions = userService.findPermissions(loginUser.getUsername());
//        List<SysResource> menus = resourceService.findMenus(permissions);
//        List<Tree> menus = resourceService.findMenuResourceTree(loginUser.getUsername());
//        model.addAttribute("menus", menus);
        return Constants.MENU_MANAGE+"/user/list";
    }

    @RequestMapping("/welcome")
    public String welcome() {
        return "welcome";
    }
    
    @RequestMapping("/forwardindex")
    public String forwardindex(String url) {
        return url;
    }
    
    @RequestMapping("/persys/left")
    public String persys(@CurrentUser SysUser loginUser, Model model) {
    	List<SysResource> menus=userService.findResourceList(loginUser.getUsername());
    	model.addAttribute("menus", menus);
        return Constants.MENU_MANAGE+"/left";
    }


}
